﻿namespace ConsoleApp3;

class if语句adnfor
{
    static void Main(string[] args)
    {
        Random random = new Random();
        int sum = 0;
        for (int i = 0; i < 10; i++)
        {
            int randomNumber = random.Next(1, 10);
            Console.Write($"{randomNumber} ");
            sum += randomNumber;
        }

        Console.WriteLine();
        Console.WriteLine(sum);

        int firstValue = 500;
        int secondValue = 600;
        int largerValue = Math.Max(firstValue, secondValue);

        Console.WriteLine(largerValue);

        Random dice = new Random();


        int roll1 = dice.Next(1, 7);
        int roll2 = dice.Next(1, 7);
        int roll3 = dice.Next(1, 7);

        int total = roll1 + roll2 + roll3;

        Console.WriteLine($"Dice roll: {roll1} + {roll2} + {roll3} = {total}");

        //再添加一个 if 语句来实现双倍奖励
        if ((roll1 == roll2) || (roll2 == roll3) || (roll1 == roll3))
        {
            Console.WriteLine("You rolled doubles! +2 bonus to total!");
            total += 2;
        }

        //再添加一个 if 语句来实现三倍奖励
        if ((roll1 == roll2) && (roll2 == roll3))
        {
            Console.WriteLine("You rolled triples! +6 bonus to total!");
            total += 6;
        }

        //添加一个 if 语句，以基于 total 变量的值显示不同的消息
        if (total >= 15)
        {
            Console.WriteLine("You win!");
        }

        if (total < 15)
        {
            Console.WriteLine("Sorry,You lose!");
        }

        //什么是布尔表达式？
        string message = "The quick brown fox jumps over the lazy dog.";
        bool result = message.Contains("sweet");
        Console.WriteLine(result);

        //Contains方法来检查该字符串是否包含子串
        if (message.Contains("qasduic"))
        {
            Console.WriteLine("What does the fox say?");
        }
        else
        {
            Console.WriteLine("What does the dog say?");
        }

        int daysUntilExpiration = random.Next(12);
        int discountPercentage = 0;
        if (daysUntilExpiration <= 10)
        {
            Console.WriteLine("Your subscription will expire soon. Renew now!");
        }
        else if (daysUntilExpiration <= 5)
        {
            Console.WriteLine($"Your subscription expires in {discountPercentage} days.\nRenew now and save 10%!");
        }
        else if (daysUntilExpiration == 1)
        {
            Console.WriteLine("Your subscription expires within a day!\nRenew now and save 20%!");
        }
        else
        {
            Console.WriteLine("Your subscription has expired.");
        }
    }
}